/*
 * SystemTimer.c
 *
 *  Created on: Mar 8, 2012
 *      Author: 234
 */
#include "Simulator.h"
#include <stdio.h>
#include <pthread.h>

void* runTimer(SystemTimer* c) {
	//static char buffer[255]; //lets assume we wont be typing more than 100 chars
    while (1) {
    	sleep(c->interval);//(int) c->interval); //TODO both of these are causing errors
    	c->interrupted = 1;
		printf("==========================SYSTEM TIMER INTERRUPT=============================\n");
		fflush(stdout);
	}
	return NULL;
}

void initializeSystemTimer(SystemTimer* c, int interval) {
	c->interval = interval;
	c->interrupted = 0;
	(void) pthread_create(&(c->systhread), NULL, runTimer, c);
}


